-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #2510 enhance derive param computed #2544
base: main
Are you sure you want to change the base?
Conversation
@@ -117,13 +117,18 @@ | |||
#' @param keep_nas Keep observations with `NA`s | |||
#' | |||
#' If the argument is set to `TRUE`, observations are added even if some of | |||
#' the values contributing to the computed value are `NA`. | |||
#' the values contributing to the computed value are `NA` (see Example 1b). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be so cool if we could hyperlink to this example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, linking to examples would be really cool.
Unfortunately, I'm not aware of an easy way to do this. We discussed creating a roclet for such improvements in #1590 but it was never implemented and I don't think we have resources for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One day we shall be great again!!
#' the values contributing to the computed value are `NA`. | ||
#' the values contributing to the computed value are `NA` (see Example 1b). | ||
#' | ||
#' If the argument is set to a list of variables, observations are added even |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So keep_nas can be TRUE, FALSE or a list of variables? I like not adding another argument but do we do this in other functions - is this common in other packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have something similar for the parameters
argument in derive_param_computed()
. I'm not sure if we do this in other functions.
I don't know how common this is in other packages but there are definitely examples in other packages. Consider for example dplyr::select()
. It accepts both symbols and strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool Cool! That is good example.
All good for me then.
@@ -1,6 +1,7 @@ | |||
url: https://pharmaverse.github.io/admiral | |||
|
|||
template: | |||
math-rendering: mathjax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intentional? Just checking!?! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I rendered the documentation with pkgdown 2.1.1 and noticed that formulas are no longer rendered correctly. Adding this line fixes the issues.
ADT = ADT.SYSBP, | ||
ADTF = ADTF.SYSBP | ||
), | ||
keep_nas = exprs(ADTF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if I do exprs(TRUE)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ keep_nas = exprs(TRUE)
+ )
Error in `derive_param_computed()`:
! Each element of the list in argument `keep_nas` must be class/type <symbol>.
ℹ But, element 1 is `TRUE`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay - was just a sanity check for me.
@yurovska does this meet your needs for this function? |
@bms63 @bundfussr Yes, sort of... It indeed gives a possibility to do what I wanted to do as described in the issue. However, users might still be falling into a trap if advs <- tribble(
~USUBJID, ~PARAMCD, ~PARAM, ~AVAL, ~AVALU, ~VISIT, ~TESTVAR,
"01-701-1015", "HEIGHT", "Height (cm)", 147.0, "cm", "SCREENING", NA_character_,
"01-701-1015", "WEIGHT", "Weight (kg)", 54.0, "kg", "SCREENING", NA_character_,
"01-701-1015", "WEIGHT", "Weight (kg)", 54.4, "kg", "BASELINE", NA_character_,
"01-701-1015", "WEIGHT", "Weight (kg)", 53.1, "kg", "WEEK 2", NA_character_,
"01-701-1028", "HEIGHT", "Height (cm)", 163.0, "cm", "SCREENING", NA_character_,
"01-701-1028", "WEIGHT", "Weight (kg)", 78.5, "kg", "SCREENING", NA_character_,
"01-701-1028", "WEIGHT", "Weight (kg)", 80.3, "kg", "BASELINE", NA_character_,
"01-701-1028", "WEIGHT", "Weight (kg)", 80.7, "kg", "WEEK 2", NA_character_
)
derive_param_computed(
dataset = advs,
by_vars = exprs(USUBJID, VISIT),
parameters = "WEIGHT",
set_values_to = exprs(
AVAL = AVAL.WEIGHT / (AVAL.HEIGHT / 100)^2,
AVALU = "kg/m^2",
PARAMCD = "BMI",
PARAM = "Body Mass Index (kg/m^2)",
TESTVAR = TESTVAR.WEIGHT
),
constant_parameters = c("HEIGHT"),
constant_by_vars = exprs(USUBJID)
)
Shall |
Yes, good idea. |
Awesome. It is much more clear for the user now. Thanks a lot! No more comments from my side. Good job @bundfussr! |
Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral codebase remains robust and consistent.
Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the
main
branch until you have checked off each task.styler::style_file()
to style R and Rmd filesinst/cheatsheet/admiral_cheatsheet.pptx
and re-upload a PDF and a PNG version of it to the same folder. (The PNG version can be created by taking a screenshot of the PDF version.)devtools::document()
so all.Rd
files in theman
folder and theNAMESPACE
file in the project root are updated appropriatelyNEWS.md
under the header# admiral (development version)
if the changes pertain to a user-facing function (i.e. it has an@export
tag) or documentation aimed at users (rather than developers). A Developer Notes section is available inNEWS.md
for tracking developer-facing issues.pkgdown::build_site()
and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.lintr::lint_package()
R CMD check
locally and address all errors and warnings -devtools::check()